﻿using System;
using System.Collections.Generic;
using System.Linq;
using StructureMap;
using StructureMap.Configuration;
using StructureMap.Configuration.DSL;
using DLM.Domain.Repositories;
using DLM.Infrastructure.UnitOfWork;
using DLM.Infrastructure.Logging;
using DLM.Infrastructure.Domain;
using DLM.Infrastructure.Configuration;
using DLM.Infrastructure.Authentication;
using DLM.Infrastructure.Email;
using DLM.Services.Interfaces;
using DLM.Services.Implementations;
using DLM.Services.BonusRule;
using DLM.Infrastructure.Payment;

namespace DLM.DependencyResolve
{
    public class RepositoryRegistry : Registry
    {
        public RepositoryRegistry()
        {
            // Repositories
            For<IAccountRepositroy>().Use<DLM.Data.EF.CodeFirst.Repositories.AccountRepository>();
            For<IUserRepository>().Use<DLM.Data.EF.CodeFirst.Repositories.UserRepository>();
            For<IFriendRepository>().Use<DLM.Data.EF.CodeFirst.Repositories.FriendRepository>();
            For<IUserPartyAssociationRepository>().Use<DLM.Data.EF.CodeFirst.Repositories.UserPartyAssociationRepository>();
            For<IPhotoRepository>().Use<DLM.Data.EF.CodeFirst.Repositories.PhotoRepository>();
            For<IAdminUserRepository>().Use<DLM.Data.EF.CodeFirst.Repositories.AdminUserRepository>();
            For<IRemarkRepository>().Use<DLM.Data.EF.CodeFirst.Repositories.RemarkRepository>();
            For<IPartyRepository>().Use<DLM.Data.EF.CodeFirst.Repositories.PartyRepository>();
            For<IBonusRepository>().Use<DLM.Data.EF.CodeFirst.Repositories.BonusRepository>();
            For<IBonusLogRepository>().Use<DLM.Data.EF.CodeFirst.Repositories.BonusLogRepository>();
            For<IInvitationRepository>().Use<DLM.Data.EF.CodeFirst.Repositories.InvitationRepository>();
            For<IMessageRepository>().Use<DLM.Data.EF.CodeFirst.Repositories.MessageRepository>();
            For<INoticeRepository>().Use<DLM.Data.EF.CodeFirst.Repositories.NoticeRepository>();
            For<ISalutationRepository>().Use<DLM.Data.EF.CodeFirst.Repositories.SalutationRepository>();
            For<ITypeRepository>().Use<DLM.Data.EF.CodeFirst.Repositories.TypeRepository>();
            For<IBreakAppointmentRepository>().Use<DLM.Data.EF.CodeFirst.Repositories.BreakAppointmentRepositroy>();
            For<IModalityRepository>().Use<DLM.Data.EF.CodeFirst.Repositories.ModalityRepository>();
            For<ISupplierRepository>().Use<DLM.Data.EF.CodeFirst.Repositories.SupplierRepository>();
            For<IUserViewRepository>().Use<DLM.Data.EF.CodeFirst.Repositories.UserViewRepository>();
            For<IEmailInvitationRepository>().Use<DLM.Data.EF.CodeFirst.Repositories.EmailInvitationRepository>();
            For<ILogRepository>().Use<DLM.Data.EF.CodeFirst.Repositories.LogRepository>();
            For<IBonusCalculateStepRepository>().Use<DLM.Data.EF.CodeFirst.Repositories.BonusCalculateStepRepository>();
            For<IPartyAlbumRepository>().Use<DLM.Data.EF.CodeFirst.Repositories.PartyAlbumRepository>();
            For<IOrderRepository>().Use<DLM.Data.EF.CodeFirst.Repositories.OrderRepository>();
            // For<IUnitOfWork>().Use<DLM.Data.EF.CodeFirst.EFUnitOfWork>();
            For<IUnitOfWork>().Use<DLM.Data.EF.CodeFirst.UnitOfWork>();
            For<IDbContext>().Use<DLM.Data.EF.CodeFirst.DLMEntities>();
            For<DLM.Data.EF.CodeFirst.IDatabaseFactory>().Use<DLM.Data.EF.CodeFirst.DatabaseFactory>();

            // Services
            For<IUserService>().Use<UserService>();
            For<IPartyService>().Use<PartyService>();
            For<IAdminService>().Use<AdminService>();
            For<IScheduleService>().Use<ScheduleService>();


            // Application Settings                 
            For<IApplicationSettings>().Use<WebConfigApplicationSettings>();

            // Logger
            For<ILogger>().Use<Log4NetAdapter>();

            // Authentication
            For<IFormsAuthentication>().Use<AspFormsAuthentication>();

            // Email
            //For<IEmailService>().Use<TextLoggingEmailService>();
            For<IEmailService>().Use<SMTPService>();

            For<IBonusRuleService>().Use<XmlRuleService>();

            // Payment service
            For<DLM.Infrastructure.Payment.IPaymentService>().Use<DLM.Infrastructure.Payment.Service>();

            For<DLM.Services.Interfaces.IPaymentService>().Use<DLM.Services.Implementations.PaymentService>();

        }
    }
}
